jQuery(function($){

  $("input.js-to-new-salary").on("click", function(){
    $("div.salary_adjusting_wrap").show();
  })

  $("input.js-to-create-adjust-log").on("click", function(e){
    e.preventDefault();
    var data = $(this).closest("form.js-tiaoxin").serializeJSON();
    var id = $(this).closest("form.js-tiaoxin").data("id");
    var csrf = $("input#js-ems-store-salaries-index").val();
    $.ajax({
      url: "/api/store_adjust_salary_logs?store_staff_id="+id,
      method: "post",
      data: data,
      headers: {
        'X-CSRF-Token': csrf
      },
      success: function(data){
        if(data.status){
          $("div.salary_adjusting_wrap").hide();
          $("input.js-my-new-salary").val(data.basic);
        }else {
          showErrorView(data.message);
        }
      }
    })
  })

  $("a.js-cancel-tiaoxindan").on("click", function(){
    $("div.salary_adjusting_wrap").hide();
  })
  
})
